﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ResourceEditor.Core;
using ResourceEditor.Core.ResourceDataObjects;

namespace Editor
{
    public partial class EditorOther : UserControl
    {
        #region Properties
        private ResourceData<object> Data { get; set; }
        #endregion

        #region Ctor
        public EditorOther()
        {
            InitializeComponent();
        }
        #endregion

        #region Methods
        internal void Clear()
        {
            dgResourceData.Rows.Clear();
            Data = null;
        }

        internal void Fill(ResourceData<object> resource)
        {
            Clear();

            Data = resource;
            foreach (var item in Data)
            {
                if (item.State != ItemState.Deleted)
                {
                    dgResourceData.Rows.Add(item.Key, item.Current.GetType().FullName);
                }
            }
        }
        #endregion

        #region Events
        private void EditorOther_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                dgResourceData.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                dgResourceData.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
        #endregion
    }
}
